<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>{{ message }}</h1>
    <h1>{{ message | capitalize }}</h1>
    <ul>
      <li v-for="(item, index) in sortList" :key="index">{{item}}</li>
    </ul>

  </div>
  <script>
    var app = new Vue({
      el: '#app',
      data: {
        message: 'hello Vue!',
        list: [
          {
            id: 1,
            sort: 2,
            name: 'A'
          },
          {
            id: 2,
            sort: 12,
            name: 'B'
          },
          {
            id: 3,
            sort: 1,
            name: 'C'
          },
          {
            id: 4,
            sort: 4,
            name: 'D'
          },
        ]
      },
      computed: {
        sortList(){
          return this.list.sort((a,b) => (a.sort - b.sort))
        },
      },
      filters:{
        
        capitalize: function (value) {
          if (!value) return ''
          value = value.toString()
          return value.charAt(0).toUpperCase() + value.slice(1)
        }
      },
    })
  </script>
</body>
</html>